import type { OperationModel } from './models';

import { requestClient } from '#/api/request';

/**
 * 获取工序数据集合
 * @param params 查询参数
 * @returns 返回查询结果
 */
export async function getOperationListApi(params?: any) {
  return requestClient.get<OperationModel[]>('/mes/process/operation/list', {
    params,
  });
}

/**
 * 分页查询工序据集合
 * @param params 分页查询参数
 * @returns 返回查询结果
 */
export async function getOperationPagedListApi(params?: PageParams) {
  return requestClient.get<PaginationResult<OperationModel>>(
    '/mes/process/operation/list-page',
    {
      params,
    },
  );
}

/**
 * 创建工序
 * @param data 要创建的工序
 * @returns 返回结果
 */
export async function createOperationApi(data: any) {
  return requestClient.post<boolean>('/mes/process/operation', data);
}

/**
 * 更新工序
 * @param id 工序 Id
 * @param data 要更新的工序
 * @returns 返回结果
 */
export async function updateOperationApi(id: number, data: any) {
  return requestClient.put<boolean>(`/mes/process/operation/${id}`, data);
}

/**
 * 删除工序
 * @param id 工序 Id
 * @returns 返回结果
 */
export async function deleteOperationApi(id: number) {
  return requestClient.delete<boolean>(`/mes/process/operation/${id}`);
}
